Repository navigation
fix(storage): throw instead of crashing on torn WAL tail reads - #1520
Merged
Merged
Conversation
adsharma
force-pushed
the
fix/torn-wal-replay-crash
branch
from
November 6, 2026 16:26
423dbf7 to
bc86a22
Compare
BufferedFileReader::read copied the full requested size after a page refill without checking that the final page held that many bytes, so a WAL truncated mid-record (ENOSPC, power loss, SIGKILL mid-commit) overran the heap buffer and crashed recovery with SIGSEGV/SIGBUS in both strict and lenient modes. Loop small reads across page boundaries and pre-validate large reads against the file size, so torn tails surface as catchable replay errors: strict mode throws and lenient mode drops the torn transaction. Add WalTest.TornWALTailInsideLargeStringRecord covering a mid-string truncation of a multi-page WAL in both modes. Also fix a pre-existing uintmax_t/uint64_t deduction error in checkpoint_test.cpp that blocked building the transaction tests.
adsharma
force-pushed
the
fix/torn-wal-replay-crash
branch
from
November 6, 2026 16:26
bc86a22 to
1b95688
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A WAL truncated mid-record (ENOSPC, power loss, SIGKILL mid-commit) crashed recovery with SIGSEGV/SIGBUS in both strict and lenient modes:
BufferedFileReader::readcopied the full requested size after a page refill without checking the short final page, overrunning the heap buffer insideWALRecord::deserialize <- dryReplay.This loops small reads across page boundaries and pre-validates large reads against the file size, so torn tails surface as catchable replay errors: strict mode throws, lenient mode drops the torn transaction (verified: strict raises
RuntimeError, lenient opens with 0 rows on the 4233-byte repro WAL).Adds
WalTest.TornWALTailInsideLargeStringRecord(verified to die with SIGSEGV without the fix, passes with it). FullWalTest.*,FrozenWALRecoveryTest.*,CheckpointRetryAfterFailureTest.*suites pass (82/82).Also includes a one-line pre-existing
uintmax_t/uint64_tfix in checkpoint_test.cpp needed to build the transaction tests with this toolchain.